//
//  STPageStyle.swift
//  iPhone
//
//  Created by Toj on 11/17/22.
//

import UIKit

enum STPageTitleFillType {
    case fair    // 均匀: 适合标题全部显示在屏幕
    case content // 内容: 适合宽度根据内容大小而定
    case const   // 固定值: 以width为准
}

enum STPageTitleLineFillType {
    case fair    // 均值: 适合标题全部显示在屏幕
    case fill    // 填充: title视图宽度
    // NOTE:
    // fill 与 content 很像 content只不过没有间隙的宽度
    // fill == content + spacing,
    // case: spacing = 0, fill === content
    case content // 内容: 适合宽度根据内容大小而定
    case const   // 固定值: 以width为准
}

// MARK: page style
class STPageViewStyle: NSObject {
    
    public var backgroundColor = UIColor.white
    // 标题样式
    private(set) var titleStyle = STPageTitleStyle()
    // 内容样式
    private(set) var contentStyle = STPageContentViewStyle()
}

// MARK: title view style
class STPageTitleStyle: NSObject {
    /// 可以滑动
    public var isScrollEnabled = true
    
    public var backgroundColor: UIColor = .white
    
    public var height: CGFloat = 44
    
    // title cell 文字样式
    private(set) var cellStyle = STPageTitleCellStyle()
    // title line 下划线样式
    private(set) var lineStyle = STPageTitleLineStyle()
    
    var lineSpacing: CGFloat {
        guard cellStyle.fillType == .content,
              lineStyle.fillType == .content
        else { return 0 }
        return lineStyle.spacing
    }
}

// MARK: title cell style
class STPageTitleCellStyle: NSObject {
    public var fillType: STPageTitleFillType = .content
    public var width = CGFloat.cg_cipher
    public var leftEdgeInset = CGFloat.zero
    public var rightEdgeInset = CGFloat.zero

    public var backgroundColor: UIColor = .white
    public var textColor: UIColor = .black
    public var textSelectedColor: UIColor = .blue
    public var textBackgroundColor: UIColor = .white
    public var textSelectedBackgroundColor: UIColor = .clear
    public var textFont: UIFont = .systemFont(ofSize: 15)
    public var textSpacing: CGFloat = 10
}
 
// MARK: title line style
class STPageTitleLineStyle: NSObject {
    
    public var isShow = false
    public var isScale = false
    public var color: UIColor = .blue
    public var height: CGFloat = 2
    public var width:  CGFloat = 0
    public var radius: CGFloat = 1
    public var backgroundColor: UIColor = .white
    
    // fillType 非 .content 无效
    public var spacing: CGFloat = 10
    public var fillType: STPageTitleLineFillType = .content
}

// MARK: - 内容样式 style
class STPageContentViewStyle: NSObject {
    public var width = CGFloat.sr_width
    public var backgroundColor: UIColor = .white
}
